/*
import Vue from 'vue'
import Vuex from 'vuex'
import { listNews, getUpNews, getNextNews, getNews, updateNews, listNewsClick } from '@/api/news'
//挂载Vuex
Vue.use(Vuex)

//创建VueX对象
const store = new Vuex.Store({
  state: {
    newsById: '', //单条新闻
    upNews: '',//上一条新闻
    nextNews: '',
    newsId: ''//新闻id
  },
  getters: {
    newsById: state => {
      if (!state.newsById) {
        state.newsById = sessionStorage.getItem('newsById')
      }
      return state.newsById
    },
    upNews: state => {
      if (!state.upNews) {
        state.upNews = sessionStorage.getItem('upNews')
      }
      return state.upNews
    },
    nextNews: state => {
      if (!state.nextNews) {
        state.nextNews = sessionStorage.getItem('nextNews')
      }
      return state.nextNews
    },
    newsId: state => {
      if (!state.newsId) {
        state.newsId = sessionStorage.getItem('newsId')
      }
      return state.newsId
    }
  },
  mutations: {
    SET_NEWSBYID(state, data) {
      sessionStorage.setItem('newsById', data)
      state.newsById = data
    },
    SET_UPNEWS(state, data) {
      sessionStorage.setItem('upNews', data)
      state.upNews = data
    },
    SET_NEXTNEWS(state, data) {
      sessionStorage.setItem('nextNews', data)
      state.nextNews = data
    },
    SET_NEWSID(state, data) {
      sessionStorage.setItem('newsId', data)
      state.newsId = data
    }
  },
  actions: {
    setNewsById({ commit }, val) {
      return new Promise((resolve, reject) => {
        getNews(val).then(res => {
          if (res.data.img){
            res.data.img = JSON.parse(res.data.img)
          }else {
            res.data.img= []
          }
          commit('SET_NEWSBYID', res.data)
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    },
    setUpNews({ commit }, val) {
      return new Promise((resolve, reject) => {
        getUpNews(val).then(response => {
          if (response.data) {
            commit('SET_UPNEWS', response.data)
          } else {
            commit('SET_UPNEWS', '已是首条')
          }
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    },
    setNextNews({ commit }, val) {
      return new Promise((resolve, reject) => {
        getNextNews(val).then(response => {
          if (response.data) {
            commit('SET_NEXTNEWS', response.data)
          } else {
            commit('SET_NEXTNEWS', '已是尾条')
          }
          resolve()
        }).catch(error => {
          reject(error)
        })
      })
    },
    setNewsId({ commit }, val) {
      commit('SET_NEWSID', val)
    }
  }
})

export default store
*/

import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import getters from './getters'

Vue.use(Vuex)

const store = new Vuex.Store({
  modules: {
    user
  },
  getters
})

export default store

